<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>centos 搭建ftp(匿名+本地用户) | FFing</title><meta name="author" content="FFing"><meta name="copyright" content="FFing"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="今天临时需要用下ftp，发现我云服务器的ftp被我改完配置后没有恢复，导致无法使用，这里记录一下，顺便存个脚本。 bash &lt;(curl https:&#x2F;&#x2F;gitee.com&#x2F;ffing&#x2F;onekey&#x2F;raw&#x2F;master&#x2F;onekey.sh) 本脚本vsftp实现：匿名+本地用户访问FTP！  流程：  创建ftp账号&#x2F;组 安装vsftpd 创建目录及文件 配置vsftpd 测试f">
<meta property="og:type" content="article">
<meta property="og:title" content="centos 搭建ftp(匿名+本地用户)">
<meta property="og:url" content="https://blog.ffing.fun/posts/20211115220453-26cdf4b7.html">
<meta property="og:site_name" content="FFing">
<meta property="og:description" content="今天临时需要用下ftp，发现我云服务器的ftp被我改完配置后没有恢复，导致无法使用，这里记录一下，顺便存个脚本。 bash &lt;(curl https:&#x2F;&#x2F;gitee.com&#x2F;ffing&#x2F;onekey&#x2F;raw&#x2F;master&#x2F;onekey.sh) 本脚本vsftp实现：匿名+本地用户访问FTP！  流程：  创建ftp账号&#x2F;组 安装vsftpd 创建目录及文件 配置vsftpd 测试f">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-11-15T14:04:53.000Z">
<meta property="article:modified_time" content="2023-01-25T10:48:56.000Z">
<meta property="article:author" content="FFing">
<meta property="article:tag" content="centos">
<meta property="article:tag" content="ftp">
<meta property="article:tag" content="vsftpd">
<meta name="twitter:card" content="summary"><link rel="shortcut icon" href="https://src.ffing.cn/hexo/img/fn_logo_32x32.png"><link rel="canonical" href="https://blog.ffing.fun/posts/20211115220453-26cdf4b7"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.staticfile.org/fancyapps-ui/4.0.31/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdnjs.cloudflare.com/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.js',
      css: 'https://cdnjs.cloudflare.com/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'centos 搭建ftp(匿名+本地用户)',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-01-25 18:48:56'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/gundongtiao.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/custom.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/auth_icon.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/home_file_list.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/full_page.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/universe.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/nav_menu.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/txmap.css"><link rel="stylesheet" href="//at.alicdn.com/t/c/font_3830672_5bphzb91mjp.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/foot.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/aside.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/other_page.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/loading_bar.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/loading_gif.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/copyright.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/right_down_button.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/mouse.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/page_bg.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/lightlight.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/51la.css"><script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script><script src="https://sdk.51.la/perf/js-sdk-perf.min.js" crossorigin="anonymous"></script><script> LA.init({id:"JwsAbeTPm16yxMNJ",ck:"JwsAbeTPm16yxMNJ"})</script><script>new LingQue.Monitor().init({id:"JwsAbeTPm16yxMNJ",sendSuspicious:true});</script><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-double-row-display@1.00/cardlistpost.min.css"/>
<style>#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags:before {content:"\A";
  white-space: pre;}#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags > .article-meta__separator{display:none}</style>
<!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box" onclick="document.getElementById(&quot;loading-box&quot;).classList.add(&quot;loaded&quot;)"><div class="loading-bg"><div class="loading-img"></div><div class="loading-image-dot"></div></div></div><script>const preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> { preloader.endLoading() })

if (false) {
  document.addEventListener('pjax:send', () => { preloader.initLoading() })
  document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}</script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/blue/pace-theme-minimal.min.css"/><script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js"></script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">10</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">23</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/archives/"><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/timeline/"><span> 更新</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog_name"><div class="back-home-button" tabindex="-1"><i class="back-home-button-icon fas fa-grip-vertical"></i><div class="back-menu-list-groups"><div class="back-menu-list-group"><div class="back-menu-list-title">网页</div><div class="back-menu-list"><a class="back-menu-item" href="https://www.ffing.cn" title="前往首页" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://src.ffing.cn/hexo/img/fn_white_logo.png"/><span class="back-menu-item-text">首页</span></a><a class="back-menu-item" href="http://pan.ffing.cn/" rel="external nofollow" title="前往alist网盘" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://src.ffing.cn/hexo/img/alist_logo.png"/><span class="back-menu-item-text">alist网盘</span></a><a class="back-menu-item" href="https://kms.ffing.cn/" rel="external nofollow" title="前往kms服务" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://src.ffing.cn/hexo/img/kms_logo.png"/><span class="back-menu-item-text">kms服务</span></a></div></div><div class="back-menu-list-group"><div class="back-menu-list-title">在线工具</div><div class="back-menu-list"><a class="back-menu-item" href="https://www.iconfont.cn" rel="noopener nofollow" title="前往阿里icon" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://src.ffing.cn/hexo/img/ali-icon_logo.png"/><span class="back-menu-item-text">阿里icon</span></a></div></div></div></div><a id="site-name" href="/"><div class="title">FFing</div><i class="fa-solid fa-house"></i></a></span><div class="mask-name-container"><center id="name-container"><a id="page-name" href="javascript:btf.scrollToDest(0, 500)">PAGE_NAME</a></center></div><div id="weather"></div><div id="tp-weather-widget"></div> <div id="menus"><div class="nav-button" id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="nav-button" id="darkmode_navswitch"><a class="darkmode_switchbutton" type="button" title="浅色和深色模式转换" onclick="switchDarkMode()"><i class="fas fa-adjust"></i></a></div><div class="nav-button" id="nav-totop"><a class="totopbtn"><i class="fas fa-arrow-up"></i><span id="percent" onclick="btf.scrollToDest(0,500)">0</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/archives/"><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/timeline/"><span> 更新</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">centos 搭建ftp(匿名+本地用户)</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-11-15T14:04:53.000Z" title="发表于 2021-11-15 22:04:53">2021-11-15</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-01-25T10:48:56.000Z" title="更新于 2023-01-25 18:48:56">2023-01-25</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Linux/">Linux</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%95%99%E7%A8%8B/">教程</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">887</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>3分钟</span></span></div></div></div><article class="post-content" id="article-container"><p>今天临时需要用下ftp，发现我云服务器的ftp被我改完配置后没有恢复，导致无法使用，这里记录一下，顺便存个脚本。</p>
<p>bash &lt;(curl <a target="_blank" rel="noopener" href="https://gitee.com/ffing/onekey/raw/master/onekey.sh">https://gitee.com/ffing/onekey/raw/master/onekey.sh</a>)</p>
<p>本脚本vsftp实现：匿名+本地用户访问FTP！</p>
<p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/11/image-66.png"></p>
<p>流程：</p>
<ul>
<li>创建ftp账号&#x2F;组</li>
<li>安装vsftpd</li>
<li>创建目录及文件</li>
<li>配置vsftpd</li>
<li>测试ftp</li>
</ul>
<h2 id="第一步，创建用户-x2F-组"><a href="#第一步，创建用户-x2F-组" class="headerlink" title="第一步，创建用户&#x2F;组"></a>第一步，创建用户&#x2F;组</h2><p>创建FTP组：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#以&quot;ftpgroup&quot;为ftp组</span><br><span class="line">groupadd ftpgroup</span><br></pre></td></tr></table></figure>

<p>创建FTP目录：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">#以&quot;/ftp&quot;为根目录，并更改属组</span><br><span class="line">mkdir /ftp</span><br><span class="line">chown :ftpgroup /ftp</span><br></pre></td></tr></table></figure>

<p>创建FTP用户：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#创建用户&quot;ffing&quot;（配置bash、家目录、组、备注）</span><br><span class="line">useradd -s /sbin/nologin -d /ftp/ffing -g ftpgroup -c &quot;FTP用户&quot; ffing</span><br></pre></td></tr></table></figure>

<h2 id="第二步，安装vsftpd"><a href="#第二步，安装vsftpd" class="headerlink" title="第二步，安装vsftpd"></a>第二步，安装vsftpd</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">#安装</span><br><span class="line">yum -y install vsftpd</span><br><span class="line">#启动</span><br><span class="line">systemctl start vsftpd</span><br><span class="line">systemctl enable vsftpd</span><br><span class="line">#防火墙放行vsftpd服务</span><br><span class="line">firewall-cmd --add-service=ftp --permanent</span><br><span class="line">firewall-cmd --reload</span><br><span class="line">###seliunx</span><br><span class="line">#查看ftpd的selinux权限</span><br><span class="line">getsebool -a  grep ftpd</span><br><span class="line">#seliunx放行ftp</span><br><span class="line">setsebool -P ftpd_full_access=on</span><br></pre></td></tr></table></figure>

<h2 id="第三步，创建目录及文件"><a href="#第三步，创建目录及文件" class="headerlink" title="第三步，创建目录及文件"></a>第三步，创建目录及文件</h2><p>vsftp默认目录树：</p>
<p>&#x2F;etc&#x2F;vsftpd&#x2F;<br>├── ftpusers<br>├── user_list<br>├── vsftpd.conf<br>└── vsftpd_conf_migrate.sh</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">#添加上面创建的ftp登录账号(白名单文件user_list)</span><br><span class="line">echo ffing &gt;&gt; /etc/vsftpd/user_list</span><br><span class="line">#####添加匿名用户访问（根据自己需求）</span><br><span class="line">echo anonymous &gt;&gt; /etc/vsftpd/user_list</span><br><span class="line">#创建chroot_list用户列表（允许切换用户目录）</span><br><span class="line">touch /etc/vsftpd/chroot_list</span><br></pre></td></tr></table></figure>

<h2 id="第四步，配置vsftpd"><a href="#第四步，配置vsftpd" class="headerlink" title="第四步，配置vsftpd"></a>第四步，配置vsftpd</h2><p>1.编辑 &#x2F;etc&#x2F;vsftpd&#x2F;vsftpd.conf</p>
<p>实现ftp默认目录为&#x2F;ftp，并锁定用户根目录禁止切换，userlist控制登陆名单</p>
<p>配置内容如下</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br></pre></td><td class="code"><pre><span class="line">#匿名登录</span><br><span class="line">anonymous_enable=YES</span><br><span class="line">#允许本地用户模式</span><br><span class="line">local_enable=YES</span><br><span class="line">#写权限</span><br><span class="line">write_enable=YES</span><br><span class="line">#本地用户模式创建文件的umask值</span><br><span class="line">local_umask=022</span><br><span class="line">dirmessage_enable=YES</span><br><span class="line">xferlog_enable=YES</span><br><span class="line">connect_from_port_20=YES</span><br><span class="line">xferlog_std_format=YES</span><br><span class="line">listen=NO</span><br><span class="line">listen_ipv6=YES</span><br><span class="line">pam_service_name=vsftpd</span><br><span class="line"></span><br><span class="line">###登录控制###</span><br><span class="line">###############################################################</span><br><span class="line">#当userlist_enable=NO</span><br><span class="line">#仅(ftpusers）中的用户禁止访问，匿名、本地用户均可以访问</span><br><span class="line"></span><br><span class="line">#当userlist_enable=YES，userlist_deny=NO</span><br><span class="line">#（user_list）中的用户可访问，（ftpusers）禁止访问，其它用户也禁止访问</span><br><span class="line">#如果（ftpusers）和（user_list）存在相同用户将禁止访问,优先禁用《ftpusers》中的用户</span><br><span class="line">#如想匿名用户也可以访问，需anonymous加入（user_list）</span><br><span class="line"></span><br><span class="line">#当userlist_enable=YES，userlist_deny=YES</span><br><span class="line">#（ftpusers和user_list）中的用户禁止访问，其它用户可以访问</span><br><span class="line">###############################################################</span><br><span class="line">userlist_enable=YES</span><br><span class="line">userlist_deny=NO</span><br><span class="line"></span><br><span class="line">tcp_wrappers=YES</span><br><span class="line"></span><br><span class="line">###指定默认目录###</span><br><span class="line">#本地用户默认目录</span><br><span class="line">local_root=/ftp</span><br><span class="line">#匿名用户默认目录</span><br><span class="line">anon_root=/ftp</span><br><span class="line"></span><br><span class="line">###锁定目录###</span><br><span class="line">#锁定根目录，禁止用户切换</span><br><span class="line">chroot_local_user=YES</span><br><span class="line">#允许写权限（否则500错误）</span><br><span class="line">allow_writeable_chroot=YES</span><br><span class="line">#启用列表</span><br><span class="line">chroot_list_enable=YES</span><br><span class="line">#写入列表内的用户允许切换用户</span><br><span class="line">chroot_list_file=/etc/vsftpd/chroot_list</span><br></pre></td></tr></table></figure>

<p>2.编辑 &#x2F;etc&#x2F;pam.d&#x2F;vsftpd</p>
<p>注释第四行：#auth required pam_shells.so</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sed -i &#x27;4s/^/#/&#x27; /etc/pam.d/vsftpd</span><br></pre></td></tr></table></figure>

<p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/11/image-57.png"></p>
<p>重启ftp</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart vsftpd</span><br></pre></td></tr></table></figure>

<h2 id="第四步，测试"><a href="#第四步，测试" class="headerlink" title="第四步，测试"></a>第四步，测试</h2><p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/11/image-58.png"></p>
<p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/11/image-59.png"></p>
<p>匿名+本地用户：网页、客户端都可以正常登录。</p>
<p>1.在&#x2F;ftp公共目录下，所有用户，具有读、执行（下载权限），</p>
<p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/11/image-60.png"></p>
<p>2.在自己用户名目录下，具有读、写、执行（上传下载权限）,其它用户无任何权限无法访问。</p>
<p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/11/image-61.png"></p>
<p>注：权限问题，删除文件或目录,和文件或目录本身权限无关，其实是删除上级目录的inode信息，所以需要删除文件，必须上级目录具备写权限</p>
<p>目录权限：（通常r、x是一起的，没有x将只能看到目录内文件名）</p>
<ul>
<li>r权限，可以看到目录内文件</li>
<li>w权限，增加、修改、删除</li>
<li>x权限，可以对目录内的文件进行下一步操作</li>
</ul>
<p>文件权限：</p>
<ul>
<li>r权限，可以查看文件内容</li>
<li>w权限，增加、修改、删除</li>
<li>x权限，执行权限</li>
</ul>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://blog.ffing.fun">FFing</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://blog.ffing.fun/posts/20211115220453-26cdf4b7.html">https://blog.ffing.fun/posts/20211115220453-26cdf4b7.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://blog.ffing.fun" target="_blank">FFing</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/centos/">centos</a><a class="post-meta__tags" href="/tags/ftp/">ftp</a><a class="post-meta__tags" href="/tags/vsftpd/">vsftpd</a></div><div class="post_share"><div class="social-share" data-image="" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://lib.baomitu.com/social-share.js/1.0.16/css/share.min.css" media="print" onload="this.media='all'"><script src="https://lib.baomitu.com/social-share.js/1.0.16/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/20211117165540-93d10bf1.html"><img class="prev-cover" src="" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">centos 安装tomcat并systemctl控制</div></div></a></div><div class="next-post pull-right"><a href="/posts/20211102152601-2853445c.html"><img class="next-cover" src="" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">centos 7 重置root密码</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/20211102152601-2853445c.html" title="centos 7 重置root密码"><img class="cover" src="" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-11-02</div><div class="title">centos 7 重置root密码</div></div></a></div><div><a href="/posts/20211117165540-93d10bf1.html" title="centos 安装tomcat并systemctl控制"><img class="cover" src="" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-11-17</div><div class="title">centos 安装tomcat并systemctl控制</div></div></a></div><div><a href="/posts/20211118115517-65c613e1.html" title="centos 部署多个tomcat并systemd控制"><img class="cover" src="" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2021-11-18</div><div class="title">centos 部署多个tomcat并systemd控制</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E4%B8%80%E6%AD%A5%EF%BC%8C%E5%88%9B%E5%BB%BA%E7%94%A8%E6%88%B7-x2F-%E7%BB%84"><span class="toc-number">1.</span> <span class="toc-text">第一步，创建用户&#x2F;组</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E4%BA%8C%E6%AD%A5%EF%BC%8C%E5%AE%89%E8%A3%85vsftpd"><span class="toc-number">2.</span> <span class="toc-text">第二步，安装vsftpd</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E4%B8%89%E6%AD%A5%EF%BC%8C%E5%88%9B%E5%BB%BA%E7%9B%AE%E5%BD%95%E5%8F%8A%E6%96%87%E4%BB%B6"><span class="toc-number">3.</span> <span class="toc-text">第三步，创建目录及文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E5%9B%9B%E6%AD%A5%EF%BC%8C%E9%85%8D%E7%BD%AEvsftpd"><span class="toc-number">4.</span> <span class="toc-text">第四步，配置vsftpd</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%AC%AC%E5%9B%9B%E6%AD%A5%EF%BC%8C%E6%B5%8B%E8%AF%95"><span class="toc-number">5.</span> <span class="toc-text">第四步，测试</span></a></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By FFing</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div><div id="footer-banner"><div class="footer-banner-links"><div class="footer-banner-left"><div class="footer-banner-left"><div id="footer-banner-tips"></div><script src="https://src.ffing.cn/hexo/js/typed.min.foot_daziji.js"></script><script>var typed = new Typed("#footer-banner-tips", {
  strings: ["你不在正经事上忧虑,就会在乱七八糟事上忧虑,能力守恒!", "折腾硬件、软件;折腾系统、平台;折腾开发、环境;折腾window、linux;折腾,折腾,瞎J8折腾."],
  startDelay: 200,
  backDelay: 2000,
  typeSpeed: 100,
  loop: true,
  backSpeed: 20
})
</script></div></div><div class="footer-banner-right"><p><a target="_blank" href="https://hexo.io/"><img src="http://src.ffing.cn/hexo/img/Frame-Hexo-blue.svg" title="框架"></a>&nbsp;<a target="_blank" href="https://butterfly.js.org/"><img src="http://src.ffing.cn/hexo/img/Theme-Butterfly.svg" title="主题"></a>&nbsp;<a target="_blank" href="https://www.upyun.com/"><img src="http://src.ffing.cn/hexo/img/CDN又拍云.svg" title="CDN加速"></a>&nbsp;<a target="_blank" href="https://www.51.la/"><img src="http://src.ffing.cn/hexo/img/Analytics-51la.svg" title="51la统计"></a>&nbsp;<a target="_blank" href="https://www.upyun.com/"><img src="http://src.ffing.cn/hexo/img/豫ICP备2021016009.svg" title="ICP备案"></a></p></div></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.staticfile.org/fancyapps-ui/4.0.31/fancybox.umd.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"></div><script src="https://src.ffing.cn/hexo/js/jquery.min.3.6.3.js"></script><canvas id="universe"></canvas><script defer src="https://src.ffing.cn/hexo/js/universe.js"></script><script defer src="https://src.ffing.cn/hexo/js/switchDarkMode.js"></script><script defer src="https://src.ffing.cn/hexo/js/nav_menu.js"></script><script async data-pjax src="https://src.ffing.cn/hexo/js/txmap.js"></script><script async src="//at.alicdn.com/t/c/font_3830672_5bphzb91mjp.js"></script><script src="https://src.ffing.cn/hexo/js/jquery.min.js"></script><script src="https://src.ffing.cn/hexo/js/weather.js"></script><script src="https://src.ffing.cn/hexo/js/foot_runtime.js"></script></div></body></html>